﻿using System.Runtime.InteropServices;

namespace RoMBot.Classes
{
    [StructLayout( LayoutKind.Explicit, Pack = 1 )]
    public class BasePawnObject
    {
        [FieldOffset( Addresses.pawnSpeed_offset )]
        public float Speed;

        [FieldOffset( Addresses.pawnClass1_offset )]
        public PawnClass Class1;

        [FieldOffset( Addresses.pawnClass2_offset )]
        public PawnClass Class2;

        [FieldOffset( Addresses.pawnLevel2_offset )]
        public int Level2;

        [FieldOffset( Addresses.pawnRace_offset )]
        public int Race;

        [FieldOffset( 0 )]
        public BasePawnDirection DirectionVector;
    }

    [StructLayout( LayoutKind.Explicit, Pack = 1 )]
    public struct BasePawnDirection
    {
        [FieldOffset( Addresses.pawnDirXUVec_offset )]
        public float X;

        [FieldOffset( Addresses.pawnDirYUVec_offset )]
        public float Y;

        [FieldOffset( Addresses.pawnDirZUVec_offset )]
        public float Z;

        public override string ToString()
        {
            return string.Format( "X: {0}, Y: {1}, Z: {2}", X, Y, Z );
        }
    }

    [StructLayout( LayoutKind.Explicit, Pack = 1 )]
    public struct BasePawnCasting
    {
        [FieldOffset( Addresses.pawnCasting_offset )]
        public float CastTime;

        [FieldOffset( Addresses.pawnCastingElapsed_offset )]
        public float CastSoFar;

        public override string ToString()
        {
            return string.Format( "Casting time: {0}, So far: {1}", CastTime, CastSoFar );
        }
    }
}
